package com.zb.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zb.entity.ZjCodeRegSet;
import com.zb.mapper.ZjCodeRegSetMapper;
import com.zb.service.ZjCodeRegSetService;
import com.zb.vo.CodeRegSetVo;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 编码登记设置表 服务实现类
 * </p>
 *
 * @author WEN
 * @since 2023-07-25
 */
@Service
public class ZjCodeRegSetServiceImpl extends ServiceImpl<ZjCodeRegSetMapper, ZjCodeRegSet> implements ZjCodeRegSetService {

    // 初始化 或 恢复初始化编码登记设置
    @Override
    public void initOrRestoreDefaultCodeRegSet(Long custAccId) {
        ZjCodeRegSet regSet = new ZjCodeRegSet();
        regSet.setId(custAccId);
        regSet.setRegister(false);
        this.saveOrUpdate(regSet);
    }

    // 获取编码登记设置
    @Override
    public CodeRegSetVo getCodeRegSet(Long custAccId) {
        ZjCodeRegSet regSet = this.getById(custAccId);
        return CodeRegSetVo.beanToVo(regSet);
    }

    // 保存编码登记设置
    @Override
    public void saveCodeRegSet(CodeRegSetVo regSetVo) {
        ZjCodeRegSet regSet = CodeRegSetVo.voToBean(regSetVo);
        this.updateById(regSet);
    }

}
